package com.linuxgt.common.service.restful;

import io.swagger.annotations.ApiOperation;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author liuteng
 * @date 17-11-17
 */
@RestController
@RequestMapping("/swagger/*")
public class SwaggerController {

    @ApiOperation(value = "hello-swagger",
            httpMethod = "GET",
            tags = "demo",
            notes = "demo",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @RequestMapping("/info")
    @ResponseBody
    public Map swgger() {
        Map map = new HashMap();
        map.put("swagger", "swagger");
        return map;
    }

    @ApiOperation(value = "当前时间",
            httpMethod = "GET",
            tags = {"系统信息", "时间"},
            notes = "系统信息",
            produces = MediaType.TEXT_PLAIN_VALUE)
    @GetMapping("/now")
    @ResponseBody
    public String currentTime() {
        System.out.println(DateTime.now().toString(DateTimeFormat.fullDateTime()));
        return DateTime.now().toString(DateTimeFormat.fullDateTime());
    }
}
